<?php

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
 */

use app\Models\User;

$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
    $password = password_hash('123456', PASSWORD_DEFAULT);
    return [
        'username' => $faker->userName,
        'password' => $password,
        'usernumber' => '2186' . $faker->numberBetween(1000000, 7000000),
        'fullname' => $faker->name,
        'role' => 1,
        'group' => $faker->numberBetween(1, 12),
        'is_alive' => true,
        'register_at' => $faker->dateTimeThisMonth,
        'last_login_at' => $faker->dateTimeThisMonth,
    ];
});

$factory->define(App\Models\Hobby::class, function (Faker\Generator $faker) {
    $userId = User::inRandomOrder()->take(1)->get()[0]->id;
    return [
        'user_id' => $userId,
        'hobby' => $faker->word,
    ];
});

